
pulse = {};

Ext.ns( "pulse", "pulse.file", "pulse.project", "pulse.workspace", "pulse.content", "pulse.server", "pulse.util", "pulse.xml", "pulse.window"
	, "pulse.image", "pulse.widget" );

//------------------------------------------------------------------------------

pulse.xml.domParser 							= new DOMImplementation();
pulse.xml.DOM_TYPE_ELEMENT				= 1;
pulse.xml.DOM_TYPE_TEXT						= 3;
pulse.htmlElementForOutputStream 	= null;

//------------------------------------------------------------------------------
pulse.xml.getText = function( oNode )
{
	var sText = "";
	var oChild = oNode.getFirstChild();
	while ( oChild != null )
	{
		sText += oChild.getNodeValue();
		oChild = oChild.getNextSibling();
	}
	return sText;
}

//------------------------------------------------------------------------------
pulse.serverRequest = function( url, callback )
{
	jQuery.ajax({
		url: url,
		method:"GET",
		dataType: "html",
		complete: callback
	});
}

//------------------------------------------------------------------------------
pulse._message = function( msg )
{
	if ( pulse.htmlElementForOutputStream != null )
	{
		pulse.htmlElementForOutputStream.innerHTML = msg + "<br/>\n" + pulse.htmlElementForOutputStream.innerHTML;
	}
}

//------------------------------------------------------------------------------
pulse.error = function( sMsg, bMsgBox )
{
	pulse._message( '<font style="color:rgb(255,0,0);"><img src="gfx/icons/error_mini.gif"/> ' + sMsg + '</font>' );
	
	if ( bMsgBox )
	{
		Ext.MessageBox.show({
		   title: 'Error',
		   msg: sMsg,
		   width:400,
		   buttons: Ext.MessageBox.OK,
		   icon: Ext.MessageBox.ERROR
	  });
	}
}

//------------------------------------------------------------------------------
pulse.exception = function( oEx, bMsgBox )
{
	//pulse._message( '<font style="color:rgb(200,0,0);"><img src="gfx/icons/error_mini.gif"/>[ exception ] File : ' + oEx.lineNumber + ', Line : ' + oEx.filename + ', ' + oEx.message + '</font>' );
	pulse._message( '<font style="color:rgb(200,0,0);"><img src="gfx/icons/error_mini.gif"/>[ exception ] ' + oEx.toString() + '</font>' );
	
	if ( bMsgBox )
	{
		Ext.MessageBox.show({
		   title: 'Exception',
		   msg: oEx.toString(),
		   width:400,
		   buttons: Ext.MessageBox.OK,
		   icon: Ext.MessageBox.ERROR
	  });
	}
}

//------------------------------------------------------------------------------
pulse.warning = function( sMsg, bMsgBox )
{
	pulse._message( '<font style="color:rgb(240,160,0);"><img src="gfx/icons/warning_mini.png"/> ' + sMsg + '</font>' );
	
	if ( bMsgBox )
	{
		Ext.MessageBox.show({
		   title: 'Warning',
		   msg: sMsg,
		   width:400,
		   buttons: Ext.MessageBox.OK,
		   icon: Ext.MessageBox.WARNING
	  });
	}
}

//------------------------------------------------------------------------------
pulse.info = function( sMsg, bMsgBox )
{
	pulse._message( sMsg );
	
	if ( bMsgBox )
	{
		Ext.MessageBox.show({
		   title: 'Info',
		   msg: sMsg,
		   width:400,
		   buttons: Ext.MessageBox.OK,
		   icon: Ext.MessageBox.INFO
	  });
	}
}

//------------------------------------------------------------------------------
pulse.debug = function( sMsg )
{
	pulse._message( '[ debug ] ' + sMsg );
}

//------------------------------------------------------------------------------
pulse.todo = function( sMsg )
{
	pulse._message( '<font style="color:rgb(50,80,255);"><img src="gfx/icons/todo_mini.gif"/> ' + sMsg + '</font>' );
}

//------------------------------------------------------------------------------
pulse.assert = function( bCondition )
{
	if ( !bCondition )
	{
		//pulse._message( '<font style="color:rgb(200,0,0);">[ assert ] File : ' + oEx.lineNumber + ', Line : ' + oEx.filename + ', ' + oEx.message + '</font>' );
		pulse._message( '<font style="color:rgb(200,0,0);"><img src="gfx/icons/error_mini.gif"/>[ assert ] ' + 'no desc yet in pulse' + '</font>' );
		
		Ext.MessageBox.show({
		   title: 'Assert',
		   msg: 'no desc yet in pulse',
		   width:400,
		   buttons: Ext.MessageBox.OK,
		   icon: Ext.MessageBox.ERROR
	  });
	}
}





